package com.longge;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Nums {

    public int[] findErrorNums(int[] nums) {

        int  dup = 0;
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i < nums.length + 1; i++) {
            list.add(i);
        }
        HashSet<Integer> set = new HashSet<>();
        for (int j : nums) {
            if (!set.add(j)) {
                dup = j;
            }
        }
        for (int num : nums) {
            list.remove(Integer.valueOf(num));
        }

        return new int[]{dup, list.get(0)};

    }
}
